package com.wander.juc.lock;

public class ShareVariableSafeExample {

    public void safeMethod() {
        int i = 0;  // 局部变量，线程安全
        i++;
        System.out.println(i); // 始终输出 1
    }

    public static void main(String[] args) {
        ShareVariableSafeExample example = new ShareVariableSafeExample();
        Integer i = Integer.valueOf(0);
        for (int j = 0; j < 10; j++) {
            new Thread(() -> {
            }).start();
        }

    }

   static class A {
        private int a;
        public void increment() {
            a++;
        }
        public int get() {
            return a;
        }
    }
}
